<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p class="test">教育</p>
    <button>平替</button>
    
</body>
 <script>
    //$&  平替前面的内容
    let text = document.querySelector(".test");
    console.log(text);
    let btn = document.querySelector("button")
    btn.addEventListener("click", ()=>{
        let reg = /教育/g
        text.innerHTML=text.innerHTML.replace(reg,`<a href="https://www.bilibili.com/">$&</a>`)
    })
 </script>
</html>